<?php

include("../class/connection.php");
$conexionSignos = new Connection();
$conexionSignos->connect();
$consultaId = $_GET['consultaId'];
$sql_pacientes = "SELECT *FROM Consulta
    INNER JOIN Signos_consulta ON Signos_consulta.Consulta_idConsulta= Consulta.idConsulta
    INNER JOIN Signos ON Signos.idSigno=Signos_consulta.Signos_idSigno
    WHERE Consulta.idConsulta=" . $consultaId;

$qry_pacienteSignos = $conexionSignos->executeQuery($sql_pacientes);
$sql_Signos = "SELECT *FROM Signos";
$qry_Signos = $conexionSignos->executeQuery($sql_Signos);
echo "<table width='100%' border='0'><tr><td width='45%'>";
echo "<u><b>Signos:</b></u>";
echo "<div id='div_Signos' style='border: 1px coral solid;width:100%; height:230px;overflow:auto;'>";
echo "<TABLE>";
$id=0;
while ($reg_Signos = mysql_fetch_assoc($qry_Signos)) {
    $codigo_Signo = $reg_Signos['idSigno'];
    echo "<tr><td>";
    $encontrado = 0;
    $qry_pacienteSignos = $conexionSignos->executeQuery($sql_pacientes);

    while ($reg_browseSigno = mysql_fetch_assoc($qry_pacienteSignos)) {
        if ($codigo_Signo == $reg_browseSigno['Signos_idSigno']) {
            $encontrado = 1;
        }
    }
    $id++;
    echo "<input type='checkbox' value='" . $codigo_Signo . "' id='chkSigno".$id."' ";
    if ($encontrado == 1) {
        echo "disabled";
    }
    echo ">";
    echo "</td>";
    echo "<TD>" . $reg_Signos['Signo'] . "</TD></TR>";
}

echo "</TABLE>";
echo "</div>";
echo "</td><td width='10%'>";
echo "<input type='button' value='>' onclick='agregar_signos(".$consultaId.")'><br/>";
echo "<div id='div_cargando_addsigno'></div>";
echo "<input type='button' value='<' onclick='quitar_signos(".$consultaId.")'>";
echo "</td><td width='45%'>";
echo "<u><b>Signos->paciente:</b></u>";
echo "<div id='div_Signos' style='border: 1px coral solid;width:100%; height:230px;overflow:auto;'>";
echo "<TABLE>";
$qry_pacienteSignos = $conexionSignos->executeQuery($sql_pacientes);
$id2=0;
while ($reg_Signos_paciente = mysql_fetch_assoc($qry_pacienteSignos)) {
    echo "<TR><td>";
    $id2=$id2+1;
    echo "<input type='checkbox' value='".$reg_Signos_paciente['Signos_idSigno']."' id='chkSignoPaciente".$id2."'>";
    echo "</td>";
    echo "<TD>" . $reg_Signos_paciente['Signo'] . "</TD></TR>";
}
echo "</TABLE>";
echo "</div>";
echo "</td><tr>";
echo "</table>";
?>
